<?php 
class model_home extends CI_Model {
	public function __construct()
	{
	    parent::__construct();
	}

	// FUNGSI UNTUK MENAMBAHKAN PESAN KE DATABSE
	public function insert_pesan()
	{
		$this->nama = $_POST['name'];
		$this->email = $_POST['email'];
		$this->pesan = $_POST['pesan'];
		$this->timestamp = time();

		$this->db->insert('guestbook', $this);
	}

	// FUNGSI UNTUK MENGAMBIL PESAN DARI DATABASE
	// OUTPUT: ARRAY
	public function get_pesan()
	{
		$this->db->order_by('timestamp', 'desc');
		$query = $this->db->get('guestbook');
        return $query->result_array();
	}
}
?>